import os,sys
import RPi.GPIO as GPIO
import subprocess
import threading
from time import sleep
from multiprocessing import Process

#sleep(20)

def check_process(name):
    child = subprocess.Popen(["pgrep","-f",name],stdout=subprocess.PIPE,shell=False)
    response = child.communicate()[0]
    if not response:
        #print 'no '+name + 'started'
        return 0
    else:
        #print  name + 'is running'
        return 1  

while 1:
    sleep(2)
    ret = check_process('main')
    if ret:
        print 'main is runnning'
    else:
        print 'main is not started'
    
